import { ref, computed } from "vue";
// 累加值
const maskIndex = ref<number>(0);
// hook
export const useModalMask = () => {
  let initialization = 0;
  // 是否需要遮罩层
  const isMask = computed(() => {
    const value = maskIndex.value;
    return initialization === 1;
  });
  // nextMaskIndex
  const nextMaskIndex = (type: string = "push") => {
    type === "push" ? maskIndex.value++ : maskIndex.value--;
    initialization = maskIndex.value;
  };

  return {
    isMask,
    nextMaskIndex,
    initialization,
  };
};
